package imgsei.wcj.com.commonbusiness.base.model;

import android.content.Context;

import com.google.gson.Gson;

import imgsei.wcj.com.commonbusiness.helper.RetrofitHelper;
import imgsei.wcj.com.commonbusiness.interfaces.service.Service;
import imgsei.wcj.com.commonbusiness.utils.GsonUtils;
import rx.subscriptions.CompositeSubscription;

public class BaseModelImp {
    private static final String TAG ="BaseModelImp";
    private static volatile Gson gson = null;

    protected Context context = null;

    protected Service service = null;
    protected CompositeSubscription compositeSubscription = null;

    protected BaseModelImp(Context context){
        this.context = context;
        if (service == null) {
            service = RetrofitHelper.getInstance(context).getServer();
        }
        if (compositeSubscription == null) {
            compositeSubscription = new CompositeSubscription();
        }

    }

    protected static Gson getGson(){
        if (gson==null){
            synchronized (BaseModelImp.class){
                gson = GsonUtils.getGson();
            }
        }
        return gson;
    }
}
